<?php
class Marketing_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();
	}
	
	function getMarketing($query=FALSE,$id=FALSE,$limit=FALSE,$offset=FALSE)
	{
		$this->db->join('tk_province','tk_marketing.id_province = tk_province.id_province');
		$this->db->join('tk_kab','tk_marketing.id_kab = tk_kab.id_kab');
		if (!$query):
			$this->db->where('id_marketing',$id);
			return $this->db->get('tk_marketing')->row();
		elseif($query=='all'):
			$this->db->limit($limit,$offset);
			$this->db->order_by('id_marketing','desc');
			return $this->db->get('tk_marketing')->result_array();
		elseif($query=='load'):
			return $this->db->get('tk_marketing')->result_array();
			return $this->db->get('tk_marketing')->result_array();
		endif;
	}

	function addMarketing($data)
	{
		$this->db->insert('tk_marketing',$data);
	}

	function editMarketing($id,$data)
	{
		$this->db->where('id_marketing',$id);
		$this->db->update('tk_marketing',$data);
	}

	function deleteMarketing($id){
		$this->db->where('id_marketing',$id);
		$this->db->delete('tk_marketing');
	}
}

